home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6441 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: sci.kun.nl!usenet
  2. From: Marian Hellema <marian@atcmp.nl>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Q. only for ostrstream experts!!!
  5. Date: 8 Feb 1996 12:02:24 GMT
  6. Organization: AT Computing, Nijmegen, the Netherlands
  7. Message-ID: <4fcoog$6q6@wn1.sci.kun.nl>
  8. References: <4fab9d$1rp@fsuj01.rz.uni-jena.de>
  9. NNTP-Posting-Host: atcmpg.atcmp.kun.nl
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
  14. X-URL: news:4fab9d$1rp@fsuj01.rz.uni-jena.de
  15.  
  16. mkt@isun04.inf.uni-jena.de (Tilo Koerbs) wrote:
  17. >
  18. >Consider:
  19. >    ostrstream buf();  // dynamic buffer
  20. >    buf << "something" << ends;
  21. >    char *p = buf.str();  // freeze buffer and return a pointer to it
  22. >
  23. >Now: How do I delete the pointer p, using 'delete' or using 'delete[]'?
  24. >
  25.  
  26. According to the april draft working paper for the ISO/ANSI
  27. standardization, ostrstream uses new[] to allocate memory (unless
  28. you supply it's strstreambuf with a different allocationfunction, which
  29. in this example is not the case).
  30. So you should use delete [] p to free it.
  31.  
  32. [  By the way, the declaration of buf should be:
  33.     ostrstream buf;  ]
  34.  
  35. Marian
  36. -- 
  37. ----------------------------------------------------------------------
  38. Marian Hellema            AT Computing, UNIX training and consultancy
  39. email: marian@atcmp.nl    P.O. Box 1428, 6501 BK Nijmegen
  40. phone: +31 24 3527225     the Netherlands
  41.  
  42.